package h0812;

import java.util.Scanner;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 高效货运
 * @date 2024/8/12 14:39
 */
public class EfficientFreightTransportation {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int wa = sc.nextInt(); //货物a的单件重量
        int wb = sc.nextInt(); //货物b的单件重量
        int wt=sc.nextInt();   //货车额定载重
        int pa = sc.nextInt(); //a货物利润
        int pb = sc.nextInt(); //b货物利润

        //暴力枚举 解方程组。
        int ma=1;
        int mb=(wt-ma*wa)/wb;

        int profit=0;
        while (mb>0){
            profit=Math.max(ma*pa+mb*pb,profit);
            ma++;
            mb=(wt-ma*wa)/wb;
        }
        System.out.println(profit);
    }
}
